package com.glodon.paas.document.storage.service;

import javax.annotation.PostConstruct;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

import com.glodon.paas.document.storage.directory.Directory;

public class DirectoryRegister implements ApplicationContextAware {
    private String name;
    private Directory directory;
    private ApplicationContext applicationContext;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Directory getDirectory() {
        return directory;
    }

    public void setDirectory(Directory directory) {
        this.directory = directory;
    }

    @PostConstruct
    public void registry() {
        StorageService storageService = applicationContext.getBean(StorageService.class);
        storageService.registry(name, directory);
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }
}
